<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/js/layer/extend/layer.ext.js"></script>
<script type="text/javascript">
    $(function(){
        trbgmoves('#d3dff2');
    });
    //创建订单 （由于和更新订单共用一个表单，所有增加了很多乱七八糟的操作）
    function  AddBatchOrder(){
        $('#BatchOrderInfo').attr('display','block');
        $('#batchOrderForm').attr('action',"<?=blang_url('orders/BatchOrder/AddBatchOrder')?>");
        $('#sbText').val(' 创 建 ');
        $('#site').val('es');
        $('#currency').val('CNY');
        $('#consumerId').val('');
        $('#freight').val('');
        $('#remark').val('');
        $('#total').val(0);
        $('#totalText').text(0);
        //清除由更新 新增的项
        $('.sku').remove();
        $('.repair').remove();
        $('.other').remove();
        $('.accessories').remove();
        //新增插入项
        var skuTextTr = "<tr class='sku'>"+
            "<td colspan='2'>" +
            "S K U ：<input type='text' id='skuText0' name='skuText[]'>"+
            " 数量：<input type='text' id='skuNum0' name='skuNum[]'  size='4'>"+
            " <input type='button' id='addItem' value=' + ' onclick='AddTr4()'>"+
            "</td></tr>";
        $('#BatchOrderInfo tr').eq(4).after(skuTextTr);
        var repairTextTr = "<tr class='repair'>"+
            "<td colspan='2'>" +
            "维修项：<input type='text' id='repairItemsText0' name='repairItemsText[]'>"+
            " 数量：<input type='text' id='repairItemsNum0' name='repairItemsNum[]' onkeyup='totalText()' size='4'>"+
            " 单价：<input type='text' id='repairItemsCost0' name='repairItemsCost[]' onkeyup='totalText()' size='4'>"+
            " <input type='button' id='addItem' value=' + ' onclick='AddTr()'>"+
            "</td></tr>";
        $('#BatchOrderInfo tr').eq(6).after(repairTextTr);
        var otherTextTr = "<tr class='other'>"+
            "<td colspan='2'>" +
            "描 述 ：<input type='text' id='otherText0' name='otherText[]'>"+
            " 数量：<input type='text' id='otherNum0' name='otherNum[]' onkeyup='totalText()' size='4'>"+
            " 单价：<input type='text' id='otherCost0' name='otherCost[]' onkeyup='totalText()' size='4'>"+
            " <input type='button' id='addItem' value=' + ' onclick='AddTr2()'>"+
            "</td></tr>";
        $('#BatchOrderInfo tr').eq(8).after(otherTextTr);
        var accessoriesTextTr = "<tr class='accessories'>"+
            "<td colspan='2'>" +
            "S K U ：<input type='text' id='accessoriesText0' name='accessoriesText[]'>"+
            " 数量：<input type='text' id='accessoriesNum0' name='accessoriesNum[]' onkeyup='totalText()' size='4'>"+
            " 单价：<input type='text' id='accessoriesCost0' name='accessoriesCost[]' onkeyup='totalText()' size='4'>"+
            " <input type='button' id='addItem' value=' + ' onclick='AddTr3()'>"+
            "</td></tr>";
        $('#BatchOrderInfo tr').eq(10).after(accessoriesTextTr);
        //获取订单号
        $.post("<?=blang_url('ajax/ajax/GetOrderId')?>",{'orderId':1},function(data){
            $('#orderId').val(data);
        });
        layer.open({
            type: 1,
            title:'新增订单信息',
            area: ['800px', '600px'], //宽高
            content: $('#BatchOrderInfo')
        });
        $("select[data-edit-select]").filterSelect();
    }
    function AddTr(){
        var sku=$('.sku').length;
        var repair=$('.repair').length;
        var tr = "<tr class='repair'>"+
                 "<td colspan='2'>" +
                 "维修项：<input type='text' id='repairItemsText"+repair+"' name='repairItemsText[]'>"+
                 " 数量：<input type='text' id='repairItemsNum"+repair+"' name='repairItemsNum[]' onkeyup='totalText()' size='4'>"+
                 " 单价：<input type='text' id='repairItemsCost"+repair+"' name='repairItemsCost[]' onkeyup='totalText()' size='4'>"+
                 " <input type='button' id='addItem' value=' + ' onclick='AddTr()'>"+
                 "</td></tr>";
        $("#BatchOrderTable tr").eq(8+repair+sku-3).after(tr);
    }
    function AddTr2(){
        var sku=$('.sku').length;
        var repair=$('.repair').length;
        var other=$('.other').length;
        var tr = "<tr class='other'>"+
            "<td colspan='2'>" +
            "描 述 ：<input type='text' id='otherText"+other+"' name='otherText[]'>"+
            " 数量：<input type='text' id='otherNum"+other+"' name='otherNum[]' onkeyup='totalText()' size='4'>"+
            " 单价：<input type='text' id='otherCost"+other+"' name='otherCost[]' onkeyup='totalText()' size='4'>"+
            " <input type='button' id='addItem' value=' + ' onclick='AddTr2()'>"+
            "</td></tr>";
        $("#BatchOrderTable tr").eq(10+repair+other+sku-4).after(tr);
    }
    function AddTr3(){
        var sku=$('.sku').length;
        var repair=$('.repair').length;
        var other=$('.other').length;
        var accessories=$('.accessories').length;
        var tr = "<tr class='accessories'>"+
            "<td colspan='2'>" +
            "S K U ：<input type='text' id='accessoriesText"+accessories+"' name='accessoriesText[]'>"+
            " 数量：<input type='text' id='accessoriesNum"+accessories+"' name='accessoriesNum[]' onkeyup='totalText()' size='4'>"+
            " 单价：<input type='text' id='accessoriesCost"+accessories+"' name='accessoriesCost[]' onkeyup='totalText()' size='4'>"+
            " <input type='button' id='addItem' value=' + ' onclick='AddTr3()'>"+
            "</td></tr>";
        $("#BatchOrderTable tr").eq(12+repair+other+accessories+sku-5).after(tr);
    }
    function AddTr4(){
        var sku=$('.sku').length;
        var tr = "<tr class='sku'>"+
            "<td colspan='2'>" +
            "S K U ：<input type='text' id='skuText"+sku+"' name='skuText[]'>"+
            " 数量：<input type='text' id='skuNum"+sku+"' name='skuNum[]'  size='4'>"+
            " <input type='button' id='addItem' value=' + ' onclick='AddTr4()'>"+
            "</td></tr>";
        $("#BatchOrderTable tr").eq(5+sku-1).after(tr);
    }
    //计算总费用
    function totalText(){
        var repair=$('.repair').length;
        var other=$('.other').length;
        var accessories=$('.accessories').length;
        var freight=$('#freight').val();
        if(freight==''){
            freight=0;
        }
        freight=parseFloat(freight);
        var total=0;
        for(var i=0;i<repair;i++){
            var repairItemsNum=$('#repairItemsNum'+i).val();
            if(repairItemsNum==''){
                repairItemsNum=0;
            }
            var repairItemsCost=$('#repairItemsCost'+i).val();
            if(repairItemsCost==''){
                repairItemsCost=0;
            }
            total+=parseFloat(repairItemsNum) * parseFloat(repairItemsCost);
        }
        for(var j=0;j<other;j++){
            var otherNum=$('#otherNum'+j).val();
            if(otherNum==''){
                otherNum=0;
            }
            var otherCost=$('#otherCost'+j).val();
            if(otherCost==''){
                otherCost=0;
            }
            total+=parseFloat(otherNum) * parseFloat(otherCost);
        }
        for(var h=0;h<accessories;h++){
            var accessoriesNum=$('#accessoriesNum'+h).val();
            if(accessoriesNum==''){
                accessoriesNum=0;
            }
            var accessoriesCost=$('#accessoriesCost'+h).val();
            if(accessoriesCost==''){
                accessoriesCost=0;
            }
            total+=parseFloat(accessoriesNum) * parseFloat(accessoriesCost);
        }
        total+=freight;
        $('#total').val(total);
        $('#totalText').text(total);
    }
    //显示详细信息
    function viewInfo(orderId){
        var h = 0;
        var i = 0;
        var j = 0;
        var k = 0;
        $('#zhandian').text('站点：');
        $('#bizhong').text('币种：');
        $('#weixiudanhao').text('维修单号：');
        $('#kehuid').text('客户：');
        $('#yunfei').text('运费：');
        $('#heji').text('合计：');
        $('#jiluren').text('记录人：');
        $('#riqi').text('日期：');
        $('#ltjilu').html('附件：');
        $('#beizhu').text('备注：');
        $('.shougong').remove();
        $('.cpsku').remove();
        $('.qita').remove();
        $('.peijian').remove();
        $('#OrderInfo').attr('display','block');
        layer.open({
            type: 1,
            title:'订单信息',
            area: ['800px', '700px'], //宽高
            content: $('#OrderInfo')
        });
        var index=layer.load(2);
        $.post("<?=blang_url('ajax/ajax/GetBatchOrderInfo')?>",{'orderId':orderId},function(data){
            if(data) {
                layer.close(index);
                var object = JSON.parse(data);
                $('#zhandian').text($('#zhandian').text() + object.site);
                $('#bizhong').text($('#bizhong').text() + object.currency);
                $('#weixiudanhao').text($('#weixiudanhao').text() + object.orderId);
                $('#kehuid').text($('#kehuid').text() + object.name);
                $('#jiluren').text($('#jiluren').text() + object.recordName);
                if (object.sku) {
                    var cpsku = JSON.parse(object.sku);
                    for (h = 0; h < cpsku.length; h++) {
                        var skuText = "<tr align='center' class='cpsku'>" +
                            "<td colspan='2'>" + cpsku[h][0] + "</td>" +
                            "<td>" + cpsku[h][1] + "</td>" +
                            "</tr>";
                        $('#orderTable tr').eq(5 + h).after(skuText);
                    }
                }
                if (object.handworkCost) {
                    var handworkCost = JSON.parse(object.handworkCost);
                    for (i = 0; i < handworkCost.length; i++) {
                        var handworkText = "<tr align='center' class='shougong'>" +
                            "<td>" + handworkCost[i][0] + "</td>" +
                            "<td>" + handworkCost[i][1] + "</td>" +
                            "<td>" + handworkCost[i][2] + "</td>" +
                            "</tr>";
                        $('#orderTable tr').eq(7 + i + h).after(handworkText);
                    }
                }
                if (object.otherCost) {
                    var otherCost = JSON.parse(object.otherCost);
                    for (j = 0; j < otherCost.length; j++) {
                        var otherText = "<tr align='center' class='qita'>" +
                            "<td>" + otherCost[j][0] + "</td>" +
                            "<td>" + otherCost[j][1] + "</td>" +
                            "<td>" + otherCost[j][2] + "</td>" +
                            "</tr>";

                        $('#orderTable tr').eq(9 + h + i + j).after(otherText);
                    }
                }
                if (object.accessoriesCost) {
                    var accessoriesCost = JSON.parse(object.accessoriesCost);
                    for (k = 0; k < accessoriesCost.length; k++) {
                        var accessoriesText = "<tr align='center' class='peijian'>" +
                            "<td>" + accessoriesCost[k][0] + "</td>" +
                            "<td>" + accessoriesCost[k][1] + "</td>" +
                            "<td>" + accessoriesCost[k][2] + "</td>" +
                            "</tr>";
                        $('#orderTable tr').eq(11 + h + i + k + j).after(accessoriesText);
                    }
                }
                $('#yunfei').text($('#yunfei').text() + object.freight);
                $('#heji').text($('#heji').text() + object.total);
                if (object.chatRecords) {
                    $('#ltjilu').html($('#ltjilu').text() + "<a  target='_black' href='" + object.chatRecords + "'>下载</a>");
                }
                $('#riqi').text($('#riqi').text() + object.time);
                $('#beizhu').text($('#beizhu').text() + object.remark);
            }
        });
    }
    //更新订单信息(由于有些项并不是必填，所以造就很多乱七八糟的判断)
    function UpdateInfo(orderId){
        var h = 0;
        var i = 0;
        var j = 0;
        var k = 0;
        $('#BatchOrderInfo').attr('display','block');
        $('#batchOrderForm').attr('action',"<?=blang_url('orders/BatchOrder/UpdateBatchOrder')?>");
        $('#orderId').val(orderId);
        $('#sbText').val(' 更 新 ');
        $('.sku').remove();
        $('.repair').remove();
        $('.other').remove();
        $('.accessories').remove();
        layer.open({
            type: 1,
            title:'更新订单信息',
            area: ['800px', '600px'], //宽高
            content: $('#BatchOrderInfo')
        });
        var index=layer.load(2);
        $.post("<?=blang_url('ajax/ajax/GetBatchOrderInfo')?>",{'orderId':orderId},function(data){
            if(data) {
                layer.close(index);
                var object = JSON.parse(data);
                $('#site').val(object.site);
                $('#currency').val(object.currency);
                $('#consumerId').val(object.consumerId);
                $('#freight').val(object.freight);
                $('#total').val(object.total);
                $('#totalText').text(object.total);
                $('#remark').text(object.remark);
                if (object.sku) {
                    var cpsku = JSON.parse(object.sku);
                    for (h = 0; h < cpsku.length; h++) {
                        var skuText = "<tr class='sku'>" +
                            "<td colspan='2'>" +
                            "S K U ：<input type='text' id='skuText" + i + "' value='" + cpsku[h][0] + "' name='skuText[]'>" +
                            " 数量：<input type='text' id='skuNum" + i + "' value='" + cpsku[h][1] + "' name='skuNum[]'  size='4'>" +
                            " <input type='button' id='addItem' value=' + ' onclick='AddTr4()'>" +
                            "</td></tr>";
                        $('#BatchOrderInfo tr').eq(4 + h).after(skuText);
                    }
                }
                if (object.handworkCost) {
                    var handworkCost = JSON.parse(object.handworkCost);
                    for (i = 0; i < handworkCost.length; i++) {
                        var handworkText = "<tr class='repair'>" +
                            "<td colspan='2'>" +
                            "维修项：<input type='text' id='repairItemsText" + i + "' value='" + handworkCost[i][0] + "' name='repairItemsText[]'>" +
                            " 数量：<input type='text' id='repairItemsNum" + i + "' value='" + handworkCost[i][1] + "' name='repairItemsNum[]' onkeyup='totalText()' size='4'>" +
                            " 单价：<input type='text' id='repairItemsCost" + i + "' value='" + handworkCost[i][2] + "' name='repairItemsCost[]' onkeyup='totalText()' size='4'>" +
                            " <input type='button' id='addItem' value=' + ' onclick='AddTr()'>" +
                            "</td></tr>";
                        $('#BatchOrderInfo tr').eq(5 + i + h).after(handworkText);
                    }
                } else {
                    var repairTextTr = "<tr class='repair'>" +
                        "<td colspan='2'>" +
                        "维修项：<input type='text' id='repairItemsText0' name='repairItemsText[]'>" +
                        " 数量：<input type='text' id='repairItemsNum0' name='repairItemsNum[]' onkeyup='totalText()' size='4'>" +
                        " 单价：<input type='text' id='repairItemsCost0' name='repairItemsCost[]' onkeyup='totalText()' size='4'>" +
                        " <input type='button' id='addItem' value=' + ' onclick='AddTr()'>" +
                        "</td></tr>";
                    $('#BatchOrderInfo tr').eq(5 + h).after(repairTextTr);
                }
                if (object.otherCost) {
                    var otherCost = JSON.parse(object.otherCost);
                    if (i == 0) {
                        i = 1;
                    }
                    for (j = 0; j < otherCost.length; j++) {
                        var otherText = "<tr class='other'>" +
                            "<td colspan='2'>" +
                            "描 述 ：<input type='text' id='otherText" + j + "' value='" + otherCost[j][0] + "' name='otherText[]'>" +
                            " 数量：<input type='text' id='otherNum" + j + "' value='" + otherCost[j][1] + "' name='otherNum[]' onkeyup='totalText()' size='4'>" +
                            " 单价：<input type='text' id='otherCost" + j + "' value='" + otherCost[j][2] + "' name='otherCost[]' onkeyup='totalText()' size='4'>" +
                            " <input type='button' id='addItem' value=' + ' onclick='AddTr2()'>" +
                            "</td></tr>";
                        $('#BatchOrderInfo tr').eq(6 + h + i + j).after(otherText);
                    }
                } else {
                    if (i == 0) {
                        i = 1;
                    }
                    var otherTextTr = "<tr class='other'>" +
                        "<td colspan='2'>" +
                        "描 述 ：<input type='text' id='otherText0' name='otherText[]'>" +
                        " 数量：<input type='text' id='otherNum0' name='otherNum[]' onkeyup='totalText()' size='4'>" +
                        " 单价：<input type='text' id='otherCost0' name='otherCost[]' onkeyup='totalText()' size='4'>" +
                        " <input type='button' id='addItem' value=' + ' onclick='AddTr2()'>" +
                        "</td></tr>";
                    $('#BatchOrderInfo tr').eq(6 + h + i).after(otherTextTr);
                }
                if (object.accessoriesCost) {
                    var accessoriesCost = JSON.parse(object.accessoriesCost);
                    if (j == 0) {
                        j = 1;
                    }
                    for (k = 0; k < accessoriesCost.length; k++) {
                        var accessoriesText = "<tr class='accessories'>" +
                            "<td colspan='2'>" +
                            "S K U ：<input type='text' id='accessoriesText" + k + "' value='" + accessoriesCost[k][0] + "' name='accessoriesText[]'>" +
                            " 数量：<input type='text' id='accessoriesNum" + k + "' value='" + accessoriesCost[k][1] + "' name='accessoriesNum[]' onkeyup='totalText()' size='4'>" +
                            " 单价：<input type='text' id='accessoriesCost" + k + "' value='" + accessoriesCost[k][2] + "' name='accessoriesCost[]' onkeyup='totalText()' size='4'>" +
                            " <input type='button' id='addItem' value=' + ' onclick='AddTr3()'>" +
                            "</td></tr>";
                        $('#BatchOrderInfo tr').eq(7 + h + i + k + j).after(accessoriesText);
                    }
                } else {
                    if (j == 0) {
                        j = 1;
                    }
                    var accessoriesTextTr = "<tr class='accessories'>" +
                        "<td colspan='2'>" +
                        "S K U ：<input type='text' id='accessoriesText0' name='accessoriesText[]'>" +
                        " 数量：<input type='text' id='accessoriesNum0' name='accessoriesNum[]' onkeyup='totalText()' size='4'>" +
                        " 单价：<input type='text' id='accessoriesCost0' name='accessoriesCost[]' onkeyup='totalText()' size='4'>" +
                        " <input type='button' id='addItem' value=' + ' onclick='AddTr3()'>" +
                        "</td></tr>";
                    $('#BatchOrderInfo tr').eq(7 + h + i + j).after(accessoriesTextTr);
                }
            }
        });
    }
    //创建订单
    function CreatOrder(){
        var consumerId=$('#consumerId').val();
        var skuText=$('#skuText0').val();
        if(consumerId==''){
            alert('客户ID不能为空！');
            return false;
        }
        if(skuText==''){
            alert('产品SKU不能为空！');
            return false;
        }
        layer.load(2);
    }
    //扣除客户余额
    function DeductionBalance(id,clineId,currency,money,orderId,name){
        if(confirm('你确定把此订单的金额扣除到对应客户吗?')){
            var index=layer.load(2);
            $.post("<?=blang_url('ajax/ajax_two/DeductionBalance')?>",
                {'id':id,'clineId':clineId,'currency':currency,'money':money,'orderId':orderId,'name':name},
                function(data){
                    if(data){
                        layer.close(index);
                        switch (data){
                            case '1':
                                layer.msg('扣除余额成功！',{icon:6});
                                $('#is_charge'+id).html("<span style='color: #00CC00'>扣减完成</span>");
                                break;
                            case '2':
                                layer.msg('扣除失败！透支额度或余额不足！',{icon:5});
                                break;
                            case '3':
                                layer.msg('扣除失败！扣减资金异常<为零或负数>！',{icon:5});
                                break;
                            case '4':
                                layer.msg('扣除失败！汇率故障,请稍后再试！',{icon:5});
                                break;
                            default :
                                layer.msg('系统未知错误!',{icon:5});
                                break;
                        }
                    }else{
                        layer.msg('扣除失败！系统错误',{icon:5});
                    }
                }
                );
        }
    }
</script>
<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
          <h1>批量单列表</h1>
          <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-list"></i>批量单列表</h3>
            </div>
            <div class="panel-body">
                <div class="well" style="padding:0 19px;">
                  <div class="row">
                    <form action="<?=blang_url('orders/BatchOrder/GetBatchOrderList')?>" method="post" name="searchform" >
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="control-label">orderId/sku/客户id/客户名</label>
                                <input class="form-control" type="text" placeholder="orderId/sku/客户id/客户名" size="80" name="keyword">
                            </div>
                        </div>

                        <div class="col-sm-8">
                            <div class="form-group" style="padding-top: 35px;">
                               <a href="<?=blang_url('orders/BatchOrder/ExportBatchOrderData'.$str)?>" class="btn btn-oms"><i class="fa fa-download"></i>&nbsp;导出数据</a>
                               <input class="btn btn-oms" type="button" style="margin: 0 5px 0 5px;" value="创建批量单" onclick="AddBatchOrder()">
                               <input class="btn btn-primary" type="submit" value="查询">
                            </div>
                        
                        </div>
                    </form>
                  </div>
                </div>
                <div class="table-responsive">
                    <table class="table table-bordered table-hover oms-table">
                      <thead>
                        <tr>
                          <td class="text-left">站点</td>
                          <td class="text-left">订单号</td>
                          <td class="text-left">客户</td>
                          <td class="text-left">手工费</td>
                          <td class="text-left">其他费</td>
                          <td class="text-right">配件费</td>
                          <td class="text-right">运费</td>
                          <td class="text-right">总计</td>
                          <td class="text-right">币种</td>
                          <td class="text-right">日期</td>
                          <td class="text-right" style="width:10%;">操作</td>
                        </tr>
                      </thead>
                      <tbody>
                        <?php if($BatchOrderList): foreach ($BatchOrderList as $key=>$row):?>
                        <tr>
                            <td class="text-left"><?=$row['site']?></td>
                            <td class="text-left"><?=$row['orderId']?></td>
                            <td class="text-left"><?=$row['name']?></td>
                            <td class="text-left"><?=$row['handworkCostTotal']?></td>
                            <td class="text-left"><?=$row['otherCostTotal']?></td>
                            <td class="text-right"><?=$row['accessoriesCostTotal']?></td>
                            <td class="text-right"><?=$row['freight']?></td>
                            <td class="text-right"><?=$row['total']?></td>
                            <td class="text-right"><?=$row['currency']?></td>
                            <td class="text-right"><?=date('Y-m-d',strtotime($row['time']))?></td>
                            <td class="text-right">
                                <a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="viewInfo('<?=$row['orderId']?>')">查看详情</a>
                                <a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="UpdateInfo('<?=$row['orderId']?>')" title="修改"><i class="fa fa-edit"></i></a>
                                
                                <?php if(in_array($this->users['account'],array('prezwang','susie','gy_0422','AlexTM','lyb','Trista','romy','Monty','邱远琴','sony'))){?>
                                <span id="is_charge<?=$row['id']?>">
                                <?php if($row['is_charge']){?>
                                    <span style="color: #00CC00">扣减完成</span>
                                <?php }else{?>
                                    <a class="btn btn-oms btn-sm" href="javascript:void(0)" onclick="DeductionBalance(<?=$row['id']?>,<?=$row['consumerId']?>,'<?=$row['currency']?>',<?=$row['total']?>,'<?=$row['orderId']?>','<?=$this->users['name']?>')">扣减金额</a>
                                <?php }?>
                                </span>
                                <?php }?>
                            </td>
                        </tr>
                        <?php endforeach; else:?>
                            <tr><th colspan="11" class="emptyNumber"><?=lang('public_mygdsj')?>....</th></tr>
                        <?php endif; ?>
                    </tbody>
                    </table>
                    <?php if($show_pages):?>
                    <div class="page">
                        <?=$show_pages?>
                    </div>
                    <?php endif;?>
                </div>
            </div>
        </div>
    </div>

    <div id="BatchOrderInfo" class="ct_content" style="display: none">
        <form id='batchOrderForm' action="<?=blang_url('orders/BatchOrder/AddBatchOrder')?>" enctype="multipart/form-data" method="post" >
            <table id="BatchOrderTable" cellspacing="0" style="border-collapse: collapse;margin-left: 40px;width: 720px;">
                <tr>
                    <td>站点：</td>
                    <td>
                        <select name="site" id="site">
                            <option value="es">es</option>
                            <option value="ru">ru</option>
                            <option value="us">us</option>
                            <option value="de">de</option>
                            <option value="uk">uk</option>
                            <option value="fr">fr</option>
                            <option value="sz">sz</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>币种：</td>
                    <td>
                        <select name="currency" id="currency">
                            <option value="CNY">人民币</option>
                            <option value="USD">美元</option>
                            <option value="GBP">英镑</option>
                            <option value="RUB">卢布</option>
                            <option value="EUR">欧元</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>维修单号：</td>
                    <td><input type="text" id="orderId" name="orderId" readonly></td>
                </tr>
                <tr>
                    <td>客户:</td>
                    <td style="overflow: visible;">
                        <select id="consumerId" name="consumerId" data-edit-select="1" style="width: 400px;">
                            <option value="">-请选择-</option>
                            <?php foreach($clineList as $row){?>
                            <option value="<?=$row['id']?>"><?=$row['name']?></option>
                            <?php }?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><h3 style="color: #ff0000">产品SKU ↓</h3></td>
                </tr>
                <tr class="sku" id="skuY">
                    <td colspan="2">
                        S K U ：<input type="text" id="skuText0" name="skuText[]">
                        数量：<input type="text" id="skuNum0" name="skuNum[]" size='4'>
                        <input type="button" id="addItem" value=" + " onclick="AddTr4()">
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><h3 style="color: #ff0000">手工费 ↓</h3></td>
                </tr>
                <tr class="repair" id="repairY">
                    <td colspan="2">
                        维修项：<input type="text" id="repairItemsText0"  name="repairItemsText[]">
                        数量：<input type="text" id="repairItemsNum0"  name="repairItemsNum[]" onkeyup="totalText()" size="4">
                        单价：<input type="text" id="repairItemsCost0"  name="repairItemsCost[]" onkeyup="totalText()" size="4">
                        <input type="button" id="addItem" value=" + " onclick="AddTr()">
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><h3 style="color: #ff0000">其他费用 ↓</h3></td>
                </tr>
                <tr class="other" id="otherY">
                    <td colspan="2">
                        描 述 ：<input type="text" id="otherText0" name="otherText[]">
                        数量：<input type="text" id="otherNum0" name="otherNum[]" size="4"  onkeyup="totalText()">
                        单价：<input type="text" id="otherCost0" name="otherCost[]" size="4"  onkeyup="totalText()">
                        <input type="button" id="addItem" value=" + " onclick="AddTr2()">
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><h3 style="color: #ff0000">配件费 ↓</h3></td>
                </tr>
                <tr class="accessories" id="accessoriesY">
                    <td colspan="2">
                        S K U ：<input type="text" id="accessoriesText0" name="accessoriesText[]">
                        数量：<input type="text" id="accessoriesNum0" name="accessoriesNum[]" size="4"  onkeyup="totalText()">
                        单价：<input type="text" id="accessoriesCost0" name="accessoriesCost[]" size="4"  onkeyup="totalText()">
                        <input type="button" id="addItem" value=" + " onclick="AddTr3()">
                    </td>
                </tr>
                <tr>
                    <td><span style="color: #ff0000">运费：</span></td>
                    <td><input type="text" id="freight" name="freight"  size="4" onkeyup="totalText()"></td>
                </tr>
                <tr>
                    <td><span style="color: #00CC00">合计：</span></td>
                    <td>
                        <input type="hidden" id="total" name="total">
                        <span style="color: #ff0000" id="totalText">0</span>
                    </td>
                </tr>
                <tr>
                    <td><span style="color: #00CC00">上传附件：</span></td>
                    <td>
                        <input type="file" id="chatRecords" name="chatRecords">
                    </td>
                </tr>
                <tr>
                    <td><span style="color: #00CC00">备注：</span></td>
                    <td>
                        <textarea style="width: 500px;height: 100px;" name="remark" id="remark"></textarea>
                    </td>
                </tr>
                <tr align="center">
                    <td colspan="2"><input type="submit" onclick="return CreatOrder()" id="sbText" value=" 创 建 " style="width: 150px;"></td>
                </tr>
            </table>
        </form>
    </div>
    <div id="OrderInfo" class="ct_content" style="display: none">
        <table id="orderTable" cellspacing="0" style="border-collapse: collapse;margin-left: 40px;width: 720px;">
            <tr>
                <td colspan="3" id="zhandian">站点：</td>
            </tr>
            <tr>
                <td colspan="3" id="bizhong">币种：</td>
            </tr>
            <tr>
                <td colspan="3" id="weixiudanhao">维修单号：</td>
            </tr>
            <tr>
                <td colspan="3" id="kehuid">客户：</td>
            </tr>
            <tr>
                <td colspan="3"><h3 style="color: #ff0000">产品SKU  ↓</h3></td>
            </tr>
            <tr>
                <th colspan="2">SKU</th>
                <th>数量</th>
            </tr>
            <tr>
                <td colspan="3"><h3 style="color: #ff0000">手工费  ↓</h3></td>
            </tr>
            <tr>
                <th>维修项</th>
                <th>数量</th>
                <th>单价</th>
            </tr>
            <tr>
                <td colspan="3"><h3 style="color: #ff0000">其他费用  ↓</h3></td>
            </tr>
            <tr>
                <th>描述</th>
                <th>数量</th>
                <th>单价</th>
            </tr>
            <tr>
                <td colspan="3"><h3 style="color: #ff0000">配件费  ↓</h3></td>
            </tr>
            <tr>
                <th>SKU</th>
                <th>数量</th>
                <th>单价</th>
            </tr>
            <tr>
                <td colspan="3" id="yunfei">运费：</td>
            </tr>
            <tr>
                <td colspan="3" id="heji">合计：</td>
            </tr>
            <tr>
                <td colspan="3" id="jiluren">记录人：</td>
            </tr>
            <tr>
                <td colspan="3" id="ltjilu">附件：</td>
            </tr>
            <tr>
                <td colspan="3" id="beizhu">备注：</td>
            </tr>
            <tr>
                <td colspan="3" id="riqi">日期：</td>
            </tr>
        </table>
    </div>

</div>
